<?php
$pageTitle = "首页";
$currentPage = "index";
if (isset($_COOKIE['user_id'])) {
    header("Location: user-index.php");
    exit();
}
include('../resource/db/db.php');
include('../resource/navbar.php');

$sql = "SELECT sets.name, COUNT(rewards.reward_id) as reward_count 
        FROM sets 
        LEFT JOIN rewards ON sets.set_id = rewards.set_id 
        WHERE sets.is_deleted=FALSE AND rewards.is_deleted=FALSE 
        GROUP BY sets.set_id 
        ORDER BY reward_count DESC 
        LIMIT 10";
$result = $conn->query($sql);
?>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="stylesheet" href="../resource/css/rank.css">
    <link rel="stylesheet" href="../resource/css/styles.css">
    <style>
        .search-container .form-group input[type="text"] {
            margin-right: 10px;
        }

        .form-group {
            margin-bottom: 1rem;
            display: flex;
        }

        .set-container {
            display: flex;
            flex-wrap: wrap;
            margin-bottom: 20px;
            margin-top: 20px;
            padding: 20px;
            border: 1px solid #ccc;
            border-radius: 5px;
        }

        .set-link {
            text-decoration: none;
            color: black;
        }

        .set {
            width: 150px;
            height: 150px;
            background-color: #f0f0f0;
            margin-right: 20px;
            margin-bottom: 20px;
            display: flex;
            justify-content: center;
            align-items: center;
            font-size: 18px;
            text-align: center;
            padding: 10px;
        }

        .box-container {
            display: flex;
            flex-wrap: wrap;
            margin-bottom: 20px;
            margin-top: 20px;
            padding: 20px;
            border: 1px solid #ccc;
            border-radius: 5px;
        }

        .box {
            width: calc(33.33% - 20px);
            height: 100px;
            background-color: #f0f0f0;
            margin-right: 20px;
            margin-bottom: 20px;
            display: flex;
            justify-content: center;
            align-items: center;
            font-size: 24px;
            text-align: center;
            padding: 10px;
        }

        .box:nth-child(3n) {
            margin-right: 0;
        }
    </style>
</head>
<body>
    <div class="container">
        <!-- 搜索框 -->
        <div class="search-container">
            <h2>搜索</h2>
            <form method="post" action="search.php">
                <div class="form-group">
                    <input type="text" id="search_term" name="search_term" class="form-control" required>
                    <button type="submit" class="btn btn-primary">🔍</button>
                </div>
            </form>
        </div>

        <h2>热门卡组</h2>
        <!-- 轮播图播放rank.php -->
    </div>
</body>
</html>
